home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 126-150 / disk_138 / modulatools / modulatools.source / messagetools.def < prev    next >
Text File  |  1992-05-06  |  5KB  |  79 lines

  1. (******************************************************************************)
  2. (*                                                                            *)
  3. (*    The global constants and variables defined in this module are optional: *)
  4. (* if you don't want to access their features, you needn't import them into   *)
  5. (* your program. The variables in the parameter lists of the procedures are   *)
  6. (* the only variables you are required to supply.                             *)
  7. (*    When describing the order in which certain routines are called, I have  *)
  8. (* adopted the curly-bracket notation of EBNF: routines in curly brackets {}  *)
  9. (* may be called an arbitrary number of times (0 to n). A, {B}, {C, {D}} thus *)
  10. (* implies that A is called once, followed by an arbitrary number of calls to *)
  11. (* to B, followed by an arbitrary number of calls to C. Each of the calls to  *)
  12. (* C may be followed by an arbitrary number of calls to D. Likewise, {{C},{D}}*)
  13. (* implies an arbitrary number of calls to C and D in any order.              *)
  14. (*                                                                            *)
  15. (******************************************************************************)
  16. (*                                                                            *)
  17. (*  Version 1.00a.002 (Beta) :   March 2, 1988                                *)
  18. (*                                                                            *)
  19. (*    These procedures were originally written under version 1.20 of the TDI  *)
  20. (* Modula-2 compiler. I have rewritten this module to operate under the v2.00 *)
  21. (* compiler. However, should you find any problem or inconsistency with the   *)
  22. (* functionality of this code, please contact me at the following address:    *)
  23. (*                                                                            *)
  24. (*                               Jerry Mack                                   *)
  25. (*                               23 Prospect Hill Ave.                        *)
  26. (*                               Waltham, MA   02154                          *)
  27. (*                                                                            *)
  28. (*    Check the module MenuUtils for TDI's (considerably less powerful) ver-  *)
  29. (* sions of my Menu and IntuitionText procedures. The modules GadgetUtils and *)
  30. (* EasyGadgets should also be of great help.                                  *)
  31. (*                                                                            *)
  32. (******************************************************************************)
  33. (*                                                                            *)
  34. (*    The source code to MessageTools is in the public domain. You may do     *)
  35. (* with it as you please.                                                     *)
  36. (*                                                                            *)
  37. (******************************************************************************)
  38.  
  39. DEFINITION MODULE MessageTools;
  40.  
  41. FROM Intuition       IMPORT WindowPtr, MenuPtr, MenuItemPtr, IntuiMessagePtr;
  42.  
  43. TYPE
  44.    ChoiceType = RECORD
  45.                    MenuChosen    : CARDINAL;
  46.                    ItemChosen    : CARDINAL;
  47.                    SubItemChosen : CARDINAL;
  48.                    ChoicePointer : MenuItemPtr;
  49.                 END; (* ChoiceType *)
  50.  
  51.  
  52.    PROCEDURE GotMessage     (VAR IMessage   : IntuiMessagePtr;
  53.                              CurrentWindow  : WindowPtr)     : BOOLEAN;
  54.  
  55.    PROCEDURE GetMenuChoice  (MenuSelection  : CARDINAL;        (* Input  *)
  56.                              FirstMenu      : MenuPtr;         (* Input  *)
  57.                              VAR MenuChoice : ChoiceType);     (* Output *)
  58.  
  59.  (* GotMessage quickly copies any message from Intuition and returns the *)
  60.  (* original to Intuition. This helps reduce the number of IntuiMessages *)
  61.  (* Intuition allocates. Since Intuition doesn't deallocate them unless  *)
  62.  (* it is reinitialized, this is definitely a desireable practice. Also, *)
  63.  (* Imessage is DISPOSEd of if it is non-NULL upon entering GotMessage.  *)
  64.  (* This means you don't have to worry about disposing of the copies of  *)
  65.  (* the Intuition messages, either. If IMessage^.Class = MenuPick, then  *)
  66.  (* you may obtain the (Sub)Item chosen by calling GetMenuChoice. If no  *)
  67.  (* message was pending from Intuition, then GotMessage returns FALSE.   *)
  68.  (* CurrentWindow is the only input, pointing to the Window in which you *)
  69.  (* wish to determine whether an Intuition message is pending.           *)
  70.  
  71.  (* GetMenuChoice determines the FIRST (Sub)Item chosen, and returns a   *)
  72.  (* a pointer to it. Be certain to check the NextSelect field of the cho-*)
  73.  (* sen (Sub)Item, as it is possible to click-select or drag-select mul- *)
  74.  (* tiple choices before releasing the right mousebutton. Thus, MenuSe-  *)
  75.  (* lection will be either IMessage^.Code or ChoicePointer^.NextSelect.  *)
  76.  
  77.  
  78. END MessageTools.
  79.